<?php
/**
 * Wraps and outputs a HTML response
 */
class HtmlWrapper extends Wrapper {	
	/**
	 * Sends character encoding header.
	 * 
	 * (non-PHPdoc)
	 * @see Wrapper::setHeaders()
	 */
	public function setHeaders() {
		// set character encoding
		if(!Servlet::$response->getCharacterEncoding()) Servlet::$response->setCharacterEncoding(Servlet::$configuration->getAttribute("application.default_character_encoding"));
	}
	
	/**
	 * Displays response: if a layout is set, displays layout (which takes over responsibility where to display individual view); else it displays individual view.
	 * 
	 * (non-PHPdoc)
	 * @see Wrapper::setResponse()
	 */
	public function setResponse() {		
		if(!defined("VIEWS_PATH")) throw new ServletException("VIEWS_PATH is not defined!");
		$strViewFile = VIEWS_PATH."/pages/".Servlet::$response->getView().".php";
		if(!file_exists($strViewFile)) throw new ServletException("View file not found: ".Servlet::$request->page->getURLPage());
		
		require_once($strViewFile);
	}
}